<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录 - 资产管理系统</title>
    <style>
        /* 基础样式重置 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
        }

        body {
            background-color: #f0f2f5;
            display: flex;
            min-height: 100vh;
            align-items: center;
            justify-content: center;
            padding: 20px;
            background-image: 
                radial-gradient(circle at 10% 20%, rgba(52, 152, 219, 0.05) 0%, transparent 20%),
                radial-gradient(circle at 90% 80%, rgba(52, 152, 219, 0.05) 0%, transparent 20%);
        }

        /* 登录卡片样式 */
        .login-container {
            width: 100%;
            max-width: 400px;
        }

        .login-card {
            background-color: #fff;
            border-radius: 12px;
            box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
            overflow: hidden;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }

        .login-card:hover {
            transform: translateY(-3px);
            box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
        }

        .card-header {
            background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
            color: white;
            padding: 28px 20px;
            text-align: center;
            position: relative;
            overflow: hidden;
        }

        .card-header::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
        }

        .card-header h3 {
            font-size: 24px;
            font-weight: 600;
            margin: 0;
            position: relative;
        }

        .card-header p {
            font-size: 14px;
            opacity: 0.9;
            margin-top: 8px;
            position: relative;
        }

        .card-body {
            padding: 30px 25px;
        }

        /* 表单样式 */
        .form-group {
            margin-bottom: 20px;
        }

        .form-label {
            display: block;
            font-weight: 500;
            margin-bottom: 8px;
            color: #34495e;
            font-size: 14px;
        }

        .form-control {
            width: 100%;
            padding: 14px 16px;
            border-radius: 8px;
            border: 1px solid #dce1e8;
            font-size: 15px;
            transition: all 0.3s ease;
            background-color: #fafbfc;
        }

        .form-control:focus {
            border-color: #3498db;
            box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
            outline: none;
            background-color: #fff;
        }

        .form-control::placeholder {
            color: #b0b7c3;
        }

        /* 按钮样式 */
        .btn-primary {
            width: 100%;
            background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
            border: none;
            padding: 14px;
            font-weight: 600;
            font-size: 16px;
            border-radius: 8px;
            color: white;
            cursor: pointer;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .btn-primary:hover {
            background: linear-gradient(135deg, #2980b9 0%, #3498db 100%);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(52, 152, 219, 0.2);
        }

        .btn-primary:disabled {
            background: linear-gradient(135deg, #bdc3c7 0%, #95a5a6 100%);
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
        }

        /* 加载动画 */
        .spinner {
            width: 18px;
            height: 18px;
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-radius: 50%;
            border-top-color: white;
            animation: spin 1s ease-in-out infinite;
            margin-right: 8px;
        }

        @keyframes spin {
            to { transform: rotate(360deg); }
        }

        /* 底部链接 */
        .form-footer {
            text-align: center;
            margin-top: 20px;
        }

        .form-footer a {
            color: #3498db;
            text-decoration: none;
            font-size: 14px;
            transition: color 0.2s ease;
        }

        .form-footer a:hover {
            color: #2980b9;
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="login-container">
        <div id="app" class="login-card">
            <div class="card-header">
                <h3>资产管理系统python版</h3>
                
            </div>
            <div class="card-body">
                <form @submit.prevent="login">
                    <div class="form-group">
                        <label for="username" class="form-label">用户名</label>
                        <input type="text" class="form-control" id="username" v-model="form.username" required placeholder="请输入用户名">
                    </div>
                    <div class="form-group">
                        <label for="password" class="form-label">密码</label>
                        <input type="password" class="form-control" id="password" v-model="form.password" required placeholder="请输入密码">
                    </div>
                    <button type="submit" class="btn-primary" :disabled="loading">
                        <span v-if="loading" class="spinner" role="status" aria-hidden="true"></span>
                        {{ loading ? '登录中...' : '登录' }}
                    </button>
                   
                </form>
            </div>
        </div>
    </div>

    <script src="/vue/vue.global.prod.js"></script>
    
    <script>
        const { createApp, ref, reactive } = Vue;
        
        createApp({
            setup() {
                const form = reactive({
                    username: '',
                    password: ''
                });
                
                const loading = ref(false);
                
                const login = async () => {
                    try {
                        loading.value = true;
                        
                        const response = await fetch('/login', {
                            method: 'POST',
                            headers: {
                                'Content-Type': 'application/x-www-form-urlencoded',
                            },
                            body: `username=${encodeURIComponent(form.username)}&password=${encodeURIComponent(form.password)}`
                        });
                        
                        loading.value = false;
                        
                        if (response.ok) {
                            window.location.href = '/dashboard';
                        } else {
                            const error = await response.text();
                            alert(error || '登录失败，请检查用户名和密码');
                        }
                    } catch (err) {
                        alert('网络错误: ' + err.message);
                        loading.value = false;
                    }
                };
                
                return {
                    form,
                    loading,
                    login
                };
            }
        }).mount('#app');
    </script>
</body>
</html>